﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartParkingServer.IService;
using SmartParkingServer.Models;
using System.Collections.Generic;
using System.Linq;
using System;

namespace SmartParkingServer.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class MenuController : ControllerBase
    {
        IMenuService _menuService;
        public MenuController(IMenuService menuService)
        {
            _menuService = menuService;
        }

        [HttpGet]
        [Route("all")]// 签权
        public IActionResult GetAllMenus()
        {
            Result<List<MenuModel>> result = new Result<List<MenuModel>>();
            try
            {
                var datas = _menuService.Query<MenuModel>(mm => mm.State == 1).ToList();

                result.Data = datas;
            }
            catch (Exception ex)
            {
                result.State = 500;
                result.ExceptionMessage = ex.Message;
            }

            return Ok(result);
        }
    }
}
